	-- get the addon namespace
local addon, ns = ...

-- get the config values
local cfg = ns.cfg

-- get the library
local lib = ns.lib

local circulationQueue = {}
local circulation3n1 = {"AB","AB","AB","AM","ABA"};
local circulation4n1 = {"AB","AB","AB","AB","AM","ABA"};
local circulation5n1 = {"AB","AB","AB","AB","AB","AM","ABA"};

local function copytable (src) 
	local tar = {}
	for i = 1 , #src do
		table.insert(tar,src[i])
	end
	return tar
end

lib.classes["MAGE"] = {}
lib.classes["MAGE"][1] = function ()

	cfg.talentname = "AF"

	lib.AddSpell("AB",{30451}) -- Arcane Blast
	lib.AddSpell("AM",{5143}) -- Arcane Missiles
	lib.AddSpell("ABA",{44425}) -- Arcane Barrage
	lib.AddSpell("VS",{114923}) -- 
	--lib.AddSpell("ma",{6117}) -- Mage Armor
	--lib.AddSpell("ap",{12042}) -- Arcane Power
	
	lib.AddAura("B_AB",36032,"debuff","player") -- Arcane Blast
	lib.AddAura("B_AM",79683,"buff","player") -- Arcane Missiles!
	lib.AddAura("B_VS",114923,"debuff","target") -- Arcane Missiles!
	--lib.AddAura("ma",6117,"buff","player") -- Mage Armor
	--lib.AddAura("apot",31572,"buff","player") -- Arcane Potency
	--lib.AddAura("ap",12042,"buff","player") -- Arcane Power
	
	cfg.plistdps = {}
	table.insert(cfg.plistdps,"VS")
	table.insert(cfg.plistdps,"GET")
	table.insert(cfg.plistdps,"end")
	
	cfg.plist=cfg.plistdps
	
	lib.myonspellcaststart = function(spell)
		--print(spell..' start')
		if spell == cfg.spells["AB"].name then
			if circulationQueue[1] == "AB" then
				table.remove(circulationQueue,1)
			end
		end
	end
	lib.myonspellcastinterrupted = function(spell)
		if spell == cfg.spells["AB"].name then
			table.insert(circulationQueue,1,"AB")
		end
	end
	lib.myonspellcastsucceeded = function(spell)
		--print(spell..' succeeded')
		if spell == cfg.spells["AM"].name then
			if circulationQueue[1] == "AM" and lib.GetAura({"B_AM"}) <= 0 then
				table.remove(circulationQueue,1)
				if lib.Power() >= 92 and table[1] ~= "AB" then
					table.insert(circulationQueue,1,"AB")
				end
			end
		elseif spell == cfg.spells["ABA"].name then
			--print('fuck')
			circulationQueue = {}
			local nextmana = (cfg.power + cfg.pactiveRegen * lib.GetSpellCD(cfg.gcd)) * 100 / cfg.powermax
			if nextmana >= 90.6 then
				circulationQueue = copytable(circulation5n1)
			else
				circulationQueue = copytable(circulation4n1)
			end
		end
	end
	
	cfg.gcd = "AB"
	
	cfg.case = {
		["VS"] = function ()
			local wait = lib.GetSpellCD(cfg.gcd)
			if cfg.casting and cfg.castEnd - cfg.now > wait then
				wait = cfg.castEnd - cfg.now
			end
			if lib.GetAura({"B_VS"}) <= wait then
				return lib.SimpleCDCheck("VS")
			end
			return nil
		end,
		["GET"] = function()
			if circulationQueue == {} or #circulationQueue == 0 then
				local nextmana = (cfg.power + cfg.pactiveRegen * lib.GetSpellCD(cfg.gcd)) * 100 / cfg.powermax
				if nextmana >= 90.6 then
					circulationQueue = copytable(circulation5n1)
				else
					circulationQueue = copytable(circulation4n1)
				end
			end
				
			if lib.GetAura({"B_AM"}) <= 0 and circulationQueue[1] == 'AM' then
				table.remove(circulationQueue,1)
				if lib.Power() >= 92 and table[1] == "ABA" then
					table.insert(circulationQueue,1,"AB")
				end
			end
		--[[
			queue = ''
			for i = 1 , #circulationQueue do
				queue = queue..circulationQueue[i]..' '
			end]]
			--print(queue)
			if (#circulationQueue > 0) then
				return lib.SimpleCDCheck(circulationQueue[1])
			end
			return nil
		end,
	}
	
	lib.rangecheck=function()
		if lib.inrange("AB") then
			lib.bdcolor(Heddframe.bd,nil)
		else
			lib.bdcolor(Heddframe.bd,{1,0,0,1})
		end
	end
	
	cfg.mode = "dps"
	lib.onclick = function()
		if cfg.mode == "dps" then
			cfg.mode = "aoe"
			cfg.plist=cfg.plistaoe
			cfg.Update=true
		else
			cfg.mode = "dps"
			cfg.plist=cfg.plistdps
			cfg.Update=true
		end
		
	end
	
	return true
end

lib.classes["MAGE"][2] = function ()

	cfg.talentname = "HF"

	lib.AddSpell("fb",{133}) -- Fireball
	lib.AddSpell("blast",{108853}) -- Fire Blast
	lib.AddSpell("lb",{44457}) -- Living Bomb
	lib.AddSpell("comb",{11129}) -- Combustion
	lib.AddSpell("s",{2948}) -- Scorch
	lib.AddSpell("pyro",{11366}) -- Pyroblast
	lib.AddSpell("EVO",{12051}) --
	
	lib.AddAura("ignite",12654,"debuff","target") -- Ignite
	lib.AddAura("B_FI",108839,"buff","player") -- Fingers of Frost
	lib.AddAura("hs",48107,"buff","player") -- Hot Streak
	lib.AddAura("pyro",48108,"buff","player") -- Hot Streak
	lib.AddAura("lb",44457,"debuff","target") -- Living Bomb
	lib.AddAura("comb",83853,"debuff","target") -- Living Bomb
	lib.AddAura("INV",116257,"buff","player") -- Fingers of Frost
	lib.AddAura("EVO",12051,"buff","player") -- Fingers of Frost
	
	
	cfg.plistdps = {}
	table.insert(cfg.plistdps,"PARAMS")
	--table.insert(cfg.plistdps,"EVO")
	table.insert(cfg.plistdps,"comb")
	table.insert(cfg.plistdps,"fb_hs")
	table.insert(cfg.plistdps,"pyro_hs")
	table.insert(cfg.plistdps,"blast_hs")
	--table.insert(cfg.plistdps,"lb_nolb")
	table.insert(cfg.plistdps,"fb_blastcd")
	table.insert(cfg.plistdps,"pyro_nohs")
	table.insert(cfg.plistdps,"fb")
	table.insert(cfg.plistdps,"end")
	
	
	cfg.plist=cfg.plistdps
	
	cfg.case = {
		
		["EVO"] = function()
			if GetUnitSpeed('player') ~= 0 then
				return nil
			end
			if inv_sel and lib.GetAura({"INV"}) - globalwait - 3 <= 0 and UnitChannelInfo('player') ~= cfg.spells['EVO'].name then
				return lib.SimpleCDCheck("EVO")
			end
			return nil
		end,
		["PARAMS"] = function()
			globalwait = lib.GetSpellCD(cfg.gcd)
			if cfg.casting and cfg.castEnd - cfg.now > globalwait then
				globalwait = cfg.castEnd - cfg.now
			end
			if lib.GetAura({'B_FI'}) > 0 or GetUnitSpeed('player') == 0 then
				movingcancast = true
			else 
				movingcancast = false
			end
			--inv_sel = select(5,GetTalentInfo(16))
			return nil
		end,
		["comb"] = function ()
			local t = lib.GetAura({"lb"})
			if cfg.lastspell == cfg.spells['pyro'].name and (not lib.SpellCasting("fb") and not lib.SpellCasting('s')) then--lib.GetAura({"ignite"})>0 and lib.GetAura({"lb"})>0 and (lib.GetAura({"pyro"})>0 or lib.GetAura({"pyro2"})>0) then
				return lib.SimpleCDCheck("comb")
			end
			return nil
		end,
		["fb_hs"] = function ()
			local t = lib.GetAura({"hs"})
			if (lib.GetAura({"pyro"}) - globalwait > 0 and t>globalwait and cfg.lastspell == cfg.spells['pyro'].name and not lib.SpellCasting("fb") ) then
				return lib.SimpleCDCheck("fb")
			end
			return nil
		end,
		["pyro_hs"] = function ()
			local t = lib.GetAura({"hs"})
			if (lib.GetAura({"pyro"}) - globalwait > 0 and t>globalwait and (lib.SpellCasting("fb") or lib.SpellCasting('s'))) or (lib.GetAura({"pyro"}) - globalwait < 4 and lib.GetAura({"pyro"}) - globalwait > 0) then
				return lib.SimpleCDCheck("pyro")
			end
			return nil
		end,
		["blast_hs"] = function ()
			local t = lib.GetAura({"hs"})
			if t>globalwait and (lib.SpellCasting("fb") or lib.SpellCasting('s')) then
				return lib.SimpleCDCheck("blast")
			end
			return nil
		end,
		["lb_nolb"] = function ()
			local t = lib.GetAura({"lb"})
			if t <= globalwait then
				return lib.SimpleCDCheck("lb")
			end
			return nil
		end,
		
		["fb_blastcd"] = function ()
			local t = lib.GetSpellCD('hs')
			if t<=globalwait then
				if movingcancast then
					return lib.SimpleCDCheck("fb")
				else
					return lib.SimpleCDCheck("s")
				end
			end
			return nil
		end,
		["pyro_nohs"] = function ()
			local t = lib.GetAura({"hs"})
			if t<=globalwait and lib.GetAura({"pyro"}) - globalwait > 0 then
				return lib.SimpleCDCheck("pyro")
			end
			return nil
		end,
		["fb"] = function ()
			if movingcancast then
				return lib.SimpleCDCheck("fb")
			else
				return lib.SimpleCDCheck("s")
			end
		end,
	}
	--[[
	lib.AddSpell("bw",{11113}) -- Blast Wave
	lib.AddSpell("fs",{2120}) -- Flamestrike
	lib.AddSpell("moa",{30482}) -- Molten Armor
	lib.AddSpell("am",{5143}) -- Arcane Missiles
	lib.AddSpell("aba",{44425}) -- Arcane Barrage
	lib.AddSpell("ma",{6117}) -- Mage Armor
	lib.AddSpell("ap",{12042}) -- Arcane Power
	
	lib.AddAura("ab",36032,"debuff","player") -- Arcane Blast
	lib.AddAura("am",79683,"buff","player") -- Arcane Missiles!
	
	lib.AddAura("apot",31572,"buff","player") -- Arcane Potency
	lib.AddAura("ap",12042,"buff","player") -- Arcane Power
	
	lib.AddAura("ma",6117,"buff","player") -- Mage Armor
	lib.AddAura("moa",30482,"buff","player") -- Molten Armor
	lib.AddAura("hs",48108,"buff","player") -- Hot Streak
	lib.AddAura("impact",64343,"buff","player") -- Impact
	lib.AddAura("pyro",92315,"debuff","target") -- Pyroblast!
	lib.AddAura("pyro2",11366,"debuff","target") -- Pyroblast
	lib.AddAura("ignite",12654,"debuff","target") -- Ignite
	lib.AddAura("lb",44457,"debuff","target") -- Living Bomb
	
	cfg.plistdps = {}
	table.insert(cfg.plistdps,"armor")
	table.insert(cfg.plistdps,"comb")
	table.insert(cfg.plistdps,"pyro_hs")
	table.insert(cfg.plistdps,"lb_nolb")
	table.insert(cfg.plistdps,"blast_impact")
	table.insert(cfg.plistdps,"s")
	table.insert(cfg.plistdps,"fb")
	table.insert(cfg.plistdps,"end")
	
	cfg.plistaoe = {}
	table.insert(cfg.plistaoe,"armor")
	table.insert(cfg.plistaoe,"lb_nolb")
	table.insert(cfg.plistaoe,"blast_impact")
	table.insert(cfg.plistaoe,"comb")
	table.insert(cfg.plistaoe,"pyro_hs")
	table.insert(cfg.plistaoe,"bw")
	table.insert(cfg.plistaoe,"fs")
	table.insert(cfg.plistaoe,"end")
	
	cfg.plist=cfg.plistdps
	
	cfg.case = {
		["armor"] = function ()
			local t = lib.GetAura({"moa","ma"})
			if t<3 then
				return lib.SimpleCDCheck("moa")
			end
			return nil
		end,
		["comb"] = function ()
			local t = lib.GetAura({"lb"})
			if lib.GetAura({"ignite"})>0 and lib.GetAura({"lb"})>0 and (lib.GetAura({"pyro"})>0 or lib.GetAura({"pyro2"})>0) then
				return lib.SimpleCDCheck("comb")
			end
			return nil
		end,
		["pyro_hs"] = function ()
			local t = lib.GetAura({"hs"})
			if t>0 then
				return lib.SimpleCDCheck("pyro")
			end
			return nil
		end,
		["blast_impact"] = function ()
			local t = lib.GetAura({"impact"})
			if t>0 then
				return lib.SimpleCDCheck("blast")
			end
			return nil
		end,
		["lb_nolb"] = function ()
			local t = lib.GetAura({"lb"})
			if t==0 then
				return lib.SimpleCDCheck("lb")
			end
			return nil
		end,
		["ab"] = function ()
			local t,n = lib.GetAura({"ab"})
			if n>=3 and lib.SpellCasting("ab") then
				return nil
			elseif n>=2 and lib.GetAura({"am"})>0 and lib.SpellCasting("ab") then
				return nil
			end
			return lib.SimpleCDCheck("ab")
		end,
		["am"] = function()
			if lib.GetAura({"am"})>0 and select(2,lib.GetAura({"ab"}))>=2 then
				return lib.SimpleCDCheck("am")
			end
			return nil
		end,
		["aba"] = function()
			if select(2,lib.GetAura({"ab"}))>=3 then
				return lib.SimpleCDCheck("aba")
			end
			return nil
		end,
		["ma"] = function()
			if lib.GetAura({"ma"})<3 then
				return lib.SimpleCDCheck("ma")
			end
			return nil
		end,
	}
	]]
	lib.rangecheck=function()
		if lib.inrange("fb") then
			lib.bdcolor(Heddframe.bd,nil)
		else
			lib.bdcolor(Heddframe.bd,{1,0,0,1})
		end
	end
	
	cfg.mode = "dps"
	lib.onclick = function()
		if cfg.mode == "dps" then
			cfg.mode = "aoe"
			cfg.plist=cfg.plistaoe
			cfg.Update=true
		else
			cfg.mode = "dps"
			cfg.plist=cfg.plistdps
			lib.changeDPSMode()
			cfg.Update=true
		end
		
	end
	
	return true
end

local globalwait = 0
local movingcancast = false
local inv_sel = false
local INV_TH = 0.2
lib.classes["MAGE"][3] = function ()

	cfg.talentname = "BF"

	lib.AddSpell("FB",{116}) -- Frost Bolt
	lib.AddSpell("IL",{30455}) -- Ice Lance
	lib.AddSpell("FFB",{44614}) -- Frostfire Bolt
	lib.AddSpell("CoC",{6117}) -- Cone of Cold
	lib.AddSpell("IB",{112948}) -- 
	lib.AddSpell("FO",{84714}) -- Frozen Orb
	lib.AddSpell("IV",{12472}) -- Icy Veins
	lib.AddSpell("MI",{84714}) -- Mirror Image
	lib.AddSpell("IG",{11426}) --
	lib.AddSpell("FBL",{2136}) --
	lib.AddSpell("EVO",{12051}) --
	lib.AddSpell("AT",{108978}) --
	
	lib.AddAura("B_IB",112948,"debuff","target") -- Fingers of Frost
	lib.AddAura("B_INV",116257,"buff","player") -- Fingers of Frost
	lib.AddAura("B_FI",108839,"buff","player") -- Fingers of Frost
	lib.AddAura("B_EVO",12051,"buff","player") -- Fingers of Frost
	lib.AddAura("B_FoF",44544,"buff","player") -- Fingers of Frost
	lib.AddAura("B_BF",57761,"buff","player") -- Brain Freeze
	lib.AddAura("B_AT",108978,"buff","player") -- Brain Freeze
	lib.AddAura("B_IV",12472,"buff","player") -- Brain Freeze
	
	cfg.gcd = "FB"
	
	cfg.plistfulldps = {}
	table.insert(cfg.plistfulldps,"PARAMS")
	table.insert(cfg.plistfulldps,"CDs")
	table.insert(cfg.plistfulldps,"IG")
	table.insert(cfg.plistfulldps,"IL_2FoF")
	table.insert(cfg.plistfulldps,"FFB_BF")
	table.insert(cfg.plistfulldps,"Bomb")
	--table.insert(cfg.plistdps,"T6")
	table.insert(cfg.plistfulldps,"IL_1FoF")
	table.insert(cfg.plistfulldps,"FB")
	table.insert(cfg.plistfulldps,"EVO")
	table.insert(cfg.plistfulldps,"FBL")
	table.insert(cfg.plistfulldps,"IL")
	table.insert(cfg.plistfulldps,"end")
	
	cfg.plistdps = {}
	table.insert(cfg.plistdps,"PARAMS")
	table.insert(cfg.plistdps,"IG")
	table.insert(cfg.plistdps,"IL_2FoF")
	table.insert(cfg.plistdps,"FFB_BF")
	table.insert(cfg.plistdps,"Bomb")
	--table.insert(cfg.plistdps,"T6")
	table.insert(cfg.plistdps,"IL_1FoF")
	table.insert(cfg.plistdps,"FB")
	table.insert(cfg.plistdps,"EVO")
	table.insert(cfg.plistdps,"FBL")
	table.insert(cfg.plistdps,"IL")
	table.insert(cfg.plistdps,"end")
	
	cfg.plistaoe = {}
	table.insert(cfg.plistaoe,"end")
	
	cfg.plist=cfg.plistdps
	
	cfg.case = {
		["CDs"] = function()
			if ns.db.cdsonboss then
				if cfg.target ~= 'worldboss' then
					return nil
				end
			end
			if UnitChannelInfo('player') == cfg.spells['EVO'].name then
				return nil
			end
			local buffs = lib.GetAuraNum("B_FoF") or 0
			if lib.GetAura({"B_BF"}) > 2 + globalwait then
				buffs = buffs + 1
			end
			if GetUnitSpeed('player') == 0 and lib.GetSpellCD("FO") <= globalwait and (lib.SpellCasting('IB') or lib.GetSpellCD("IB") > 2) and (inv_sel and lib.GetAura({"B_INV"}) - globalwait >= 10) and ((lib.GetSpellCD("IV") <= 2 and lib.GetSpellCD("AT") <= 2) or (lib.GetSpellCD("IV") >= 15 and lib.GetSpellCD("AT") >= 20)) then
				return lib.SimpleCDCheck("FO")
			elseif lib.GetSpellCD("IV") <= globalwait and (lib.SpellCasting('IB') or lib.GetSpellCD("IB") > 5) and (lib.GetSpellCD("AT") <= 1 or lib.GetSpellCD("AT") >= 20) and (inv_sel and lib.GetAura({"B_INV"}) - globalwait >= 20) then
				return lib.SimpleCDCheck("IV")
			elseif lib.GetAura({"AT"}) <= 0 and lib.GetSpellCD("AT") <= globalwait and ((lib.GetAura({"B_IV"}) - globalwait >= 6 and lib.GetAura({"B_IV"}) - globalwait <= 9) or (lib.GetAura({"B_IV"}) - globalwait >= 9 and buffs >= 3) or (buffs >= 3 and lib.GetSpellCD("IV") >= 60)) and (inv_sel and lib.GetAura({"B_INV"}) - globalwait >= 6) then
				return lib.SimpleCDCheck("AT")
			end
			return nil
		end,
		["PARAMS"] = function()
			globalwait = lib.GetSpellCD(cfg.gcd)
			if cfg.casting and cfg.castEnd - cfg.now > globalwait then
				globalwait = cfg.castEnd - cfg.now
			end
			if lib.GetAura({'B_FI'}) > 0 or GetUnitSpeed('player') == 0 then
				movingcancast = true
			else 
				movingcancast = false
			end
			inv_sel = select(5,GetTalentInfo(16))
			return nil
		end,
		["IG"] = function()
			if UnitHealth('player') * 100 / UnitHealthMax('player') <= 80 and ns.db.cdsonboss ~= 'worldboss' then
				return lib.SimpleCDCheck("IG")
			end
			return nil
		end,
		["EVO"] = function()
			if GetUnitSpeed('player') ~= 0 then
				return nil
			end
			if inv_sel and lib.GetAura({"B_INV"}) - globalwait - 3 <= 0 and UnitChannelInfo('player') ~= cfg.spells['EVO'].name then
				return lib.SimpleCDCheck("EVO")
			end
			return nil
		end,
		["IL_2FoF"] = function()
			if lib.GetSpellCD("AT") <= globalwait and lib.GetAura({"AT"}) <= 0 then
				if cfg.dpsmode == 'full' then
					if (ns.db.cdsonboss and cfg.target == 'worldboss') or not ns.db.cdsonboss then
						return nil
					end
				end
			end
			if inv_sel and lib.GetAura({"B_INV"}) < globalwait + INV_TH and GetUnitSpeed('player') == 0 and UnitChannelInfo('player') ~= cfg.spells['EVO'].name then
				return nil
			end
			if (lib.GetAuraNum("B_FoF")>=2 and not (lib.GetAura({"B_IB"}) - globalwait >= 0.1 and lib.GetAura({"B_IB"}) - globalwait <= 2 and lib.GetAura({'B_BF'})>0)) or (lib.GetAura({"B_FoF"}) - lib.GetSpellCD(cfg.gcd) <= 3 and lib.GetAura({"B_FoF"}) - lib.GetSpellCD(cfg.gcd) > 0 ) then
				return lib.SimpleCDCheck("IL")
			end
			return nil
		end,
		["FFB_BF"] = function()
			if lib.GetSpellCD("AT") <= globalwait and lib.GetAura({"AT"}) <= 0 then
				if cfg.dpsmode == 'full' then
					if (ns.db.cdsonboss and cfg.target == 'worldboss') or not ns.db.cdsonboss then
						return nil
					end
				end
			end
			if inv_sel and lib.GetAura({"B_INV"}) < globalwait + INV_TH and GetUnitSpeed('player') == 0 and UnitChannelInfo('player') ~= cfg.spells['EVO'].name then
				return nil
			end
			if lib.GetAura({"B_BF"})>0 and ((lib.GetAura({"B_IB"}) - globalwait >= 0.1 and lib.GetAura({"B_IB"}) - globalwait <= 2) or not (lib.GetAuraNum("B_FoF") == 1 and lib.SpellCasting("FB"))) then
				return lib.SimpleCDCheck("FFB")
			end
			return nil
		end,
		["Bomb"] = function()
			if not movingcancast then
				return nil
			end
			
			if inv_sel and lib.GetAura({"B_INV"}) < globalwait + INV_TH + cfg.spells['IB'].castingTime/1000 and UnitChannelInfo('player') ~= cfg.spells['EVO'].name then
				return nil
			end
			local react = 0.5
			if not lib.SpellCasting("IB") and lib.GetSpellCD("IB") - globalwait <= react then
				return lib.SimpleCDCheck("IB",0,true)
			end
		end,
		["IL_1FoF"] = function()
			if lib.GetSpellCD("AT") <= globalwait and lib.GetAura({"AT"}) <= 0 then
				if cfg.dpsmode == 'full' then
					if (ns.db.cdsonboss and cfg.target == 'worldboss') or not ns.db.cdsonboss then
						return nil
					end
				end
			end
			if inv_sel and lib.GetAura({"B_INV"}) < globalwait + INV_TH and GetUnitSpeed('player') == 0 and UnitChannelInfo('player') ~= cfg.spells['EVO'].name then
				return nil
			end
			if lib.GetAuraNum("B_FoF")==1 then
				return lib.SimpleCDCheck("IL")
			end
			return nil
		end,
		["FB"] = function()
			if not movingcancast then
				return nil
			end
			if inv_sel and lib.GetAura({"B_INV"}) < globalwait + INV_TH + cfg.spells['FB'].castingTime/1000 and UnitChannelInfo('player') ~= cfg.spells['EVO'].name then
				return nil
			end
			return lib.SimpleCDCheck("FB")
		end,
	}
	
	lib.rangecheck=function()
		if lib.inrange("FB") then
			lib.bdcolor(Heddframe.bd,nil)
		else
			lib.bdcolor(Heddframe.bd,{1,0,0,1})
		end
	end
	
	cfg.mode = "dps"
	lib.onclick = function()
		if cfg.mode == "dps" then
			cfg.mode = "aoe"
			cfg.plist=cfg.plistaoe
			cfg.Update=true
		else
			cfg.mode = "dps"
			cfg.plist=cfg.plistdps
			lib.changeDPSMode()
			cfg.Update=true
		end
		
	end
	
	return true
end

lib.classevents["MAGE"] = function()
	cfg.spellcaster=true
end